package com.larry.jdbc.test;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class JdbcRunner {

	public static void main(String[] args) {
		DataSource dataSource = new DataSource();
		Connection connection = null;
		PreparedStatement stmt = null;
		try {
			connection = dataSource.getConnection();
			stmt = connection.prepareStatement("insert into customer (age, name) values (?, ?)");
			stmt.setInt(1, 30);
			stmt.setString(2, "Larry");
			stmt.executeUpdate();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (stmt != null) {
					stmt.close();
				}
			} catch (Exception e2) {
				e2.printStackTrace();
			}
			try {
				if (connection != null) {
					connection.close();
				}
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
	}
}
